import 'package:flutter/material.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/common/pay_type_item.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/controllers/order_controller/store_order_pay_page_controller.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:xinxuan/router/app_routers.dart';
// import 'package:xinxuan/utils/bank_code_util.dart';
import 'package:xinxuan/utils/color_util.dart';

class StoreOrderPayPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    Map<String, dynamic> argumentsMap = Get.arguments;
    bool isDetail = argumentsMap['isDetail'];
    bool isOrderPage = argumentsMap['isOrderPage'] ?? false;
    return GetBuilder<StoreOrderPayPageController>(
      init: StoreOrderPayPageController(),
      builder: (controller) {
        return Scaffold(
          backgroundColor: pageBgColor,
          appBar: AppBarUtil(
            title: '订单支付',
            backgroundColor: pageBgColor,
          ),
          body: ScrollConfigurationCommon(child: ListView(
            children: [
              Container(
                padding: EdgeInsets.only(top: 43.h, bottom: 35.h),
                color: bgWhiteColor,
                child: Column(
                  children: [
                    Text(
                      '支付金额',
                      style: TextStyle(
                        color: textSubtitleColor,
                        fontSize: 14.sp
                      ),
                    ),
                    SizedBox(height: 12.h),
                    Text.rich(
                      TextSpan(
                        text: '¥',
                        style: TextStyle(
                          color: mainTextColor,
                          fontSize: 30.sp,
                          fontWeight: FontWeight.bold
                        ),
                        children: [
                          TextSpan(
                            text: '${controller.orderDetailData.value.payableAmount}',
                            style: TextStyle(
                              color: mainTextColor,
                              fontSize: 40.sp,
                              fontWeight: FontWeight.bold
                            )
                          )
                        ]
                      )
                    )
                  ],
                ),
              ),
              SizedBox(height: 12.h),
              Obx(() => Container(
                color: bgWhiteColor,
                padding: EdgeInsets.symmetric(horizontal: 14.w),
                child: Column(
                  children: [
                    Container(
                      height: 36.h,
                      padding: EdgeInsets.symmetric(horizontal: 4.w),
                      alignment: Alignment.centerLeft,
                      decoration: BoxDecoration(
                        border: Border(
                          bottom: BorderSide(
                            width: .5,
                            color: lineColor 
                          )
                        )
                      ),
                      child: Text(
                        '支付方式',
                        style: TextStyle(
                          color: textSubtitleColor,
                          fontSize: 14.sp
                        ),
                      ),
                    ),
                    PayTypeItem(
                      iconPath: 'assets/icons/icon_alipay.png',
                      title: '支付宝支付', 
                      isSelected: controller.payType.value == 0, 
                      onTap: () {
                        controller.payType.value = 0;
                      }
                    ),
                    PayTypeItem(
                      iconPath: 'assets/icons/icon_wechar.png',
                      title: '微信支付', 
                      isSelected: controller.payType.value == 1,
                      showBorder: false,
                      onTap: () {
                        controller.payType.value = 1;
                      }
                    ),
                    // Column(
                    //   children: controller.payBankArr.map((item) {
                    //     return PayTypeItem(
                    //       iconPath: BankCodeUtil.getBankLogo(item.bank!.code!),
                    //       title: '${item.bank!.title}', 
                    //       isSelected: controller.payType.value == 3 && controller.fastPaymentId.value == item.id!,
                    //       onTap: () {
                    //         controller.payType.value = 3;
                    //         controller.fastPaymentId.value = item.id!;
                    //       }
                    //     );
                    //   }).toList(),
                    // ),
                    // PayTypeItem(
                    //   iconPath: 'assets/icons/icon_add_big.png',
                    //   title: '使用新卡支付', 
                    //   isSelected: false,
                    //   showRigth: true,
                    //   onTap: () {
                    //     Get.toNamed('${AppRouters.COMMON_PAGE}${AppRouters.MY_INFO_PAGE}${AppRouters.BANK_PAGE}${AppRouters.COMMON_BANK_PAGE}');
                    //   }
                    // ),
                    
                    // PayTypeItem(
                    //   iconPath: 'assets/icons/icon_union_pay.png',
                    //   title: '银联', 
                    //   isSelected: controller.payType.value == 2, 
                    //   onTap: () {
                    //     controller.payType.value = 2;
                    //   }
                    // ),
                  ],
                ),
              ))
            ],
          )),
          bottomNavigationBar: BottomAppBar(
            elevation: 0,
            child: Container(
              height: 56.h,
              alignment: Alignment.center,
              padding: EdgeInsets.symmetric(horizontal: 12.w),
              child: ButtonUtil(
                text: '确认支付', 
                fontSize: 14.sp, 
                borderRadius: 18.w, 
                height: 36.h, 
                onTop: () {
                  controller.confirmPay(isDetail, isOrderPage);
                }
              ),
            ),
          ),
        );
      },
    );
  }
}